package com.fub.positioning;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Measurement {
	private Map<String, Integer> accessPoints;

	/**
	 * Constructs a new measurement.
	 */
	public Measurement() {
		this.accessPoints = new HashMap<String, Integer>();
	}

	/**
	 * Returns the id's of all access points.
	 * 
	 * @return the id's of all access points
	 */
	public Set<String> getSSids() {
		return this.accessPoints.keySet();
	}

	/**
	 * Returns the signal strength of an access point.
	 * 
	 * @param ssid
	 *            the ssid of the access point
	 * @return the signal strength of an access point
	 */
	public int getSingnalStrength(String ssid) {
		if (this.accessPoints.get(ssid) == null) {
			return -1;
		} else {
			return this.accessPoints.get(ssid);
		}
	}

	/**
	 * Creates a new access point.
	 * 
	 * @param ssid
	 *            the ssid of the new access point
	 * @param signalStrength
	 *            the signal strength of the new access point
	 */
	public void putSignalStrength(String ssid, int signalStrength) {
		this.accessPoints.put(ssid, signalStrength);
	}

	/**
	 * Removes an access point.
	 * 
	 * @param ssid
	 *            the ssid of the access point
	 */
	public void removeAccessPoint(String ssid) {
		this.accessPoints.remove(ssid);
	}

	@Override
	public String toString() {
		String result = "";
		for (String ssid : this.accessPoints.keySet()) {
			result += ssid + ":" + this.accessPoints.get(ssid) + "\n";
		}
		return result;
	}
}
